import API from '../../../api/request'
import DeviceInfo from 'react-native-device-info'

const version = DeviceInfo.getVersion()

export const list = [
  {
    title: '完善资料',
    action: 'information',
    tips: ''
  },
  {
    title: '绑定手机号',
    action: 'bindPhone',
    tips: '',
    last: true
  },
//   {
//     title: '清除缓存',
//     tips: '',
//     type: 3
//   },
//   {
//     title: '我要反馈',
//     tips: '',
//     last: true
//   },
	{
		type: 5,
    title: '检查更新',
    tips: version
  },
//   {
//     title: '关于我们',
//     tips: ''
//   },
  {
		action: 'useragreement',
    title: '用户协议',
    tips: '',
    last: true
  },

  {
    type: 4,
    title: '退出登录',
    tips: '',
    last: true
  }
]

// 获得最新版本
export async function getUpdateVersion (appType) {
	let url = '/api/system/curVersion/'+appType
	let res = await API.post(url)
	if (res && res.code === '200'){
		return filterversion(res.data)
	}
}

function filterversion (data) {
		let {updateContent:desc, downloadAddress: url, appVersion:version} = data
		return {
			url,
			desc,
			version
		}
	}
